//
//  XMLParser.h
//  Portable Traffic Signal Assistor
//
//  Created by Hao Xu on 4/1/12.
//  Copyright (c) 2012 TTU. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "GDataXMLNode.h"
#import "TimerGroup.h"
#import "Signal.h"
#import "SignalRing.h"
#import "SignalPhase.h"
#import "Agency.h"
#import "SubSystem.h"
#import "TimingPattern.h"
#import "TimeRange.h"
#import "Link.h"
#import "Intersection.h"
#import "NEMASignal.h"
@interface XMLParser : NSObject


+ (void) loadDataXML;
+ (void) loadTempXML;
+ (NSString *)dataTempFilePath;
+ (void) saveDataXML;
+ (void) createNewProject;

+ (NSArray *)getTimerGroupList;
+ (NSMutableArray *)getSignalListByTimerGroupID:(NSString *) timerGroupID;
+ (Signal *)getSignalByTimerGroupIDAndSignalID:(NSString *) timerGroupID signalID:(NSString *) signalID;
+ (TimerGroup *)getTimerGroup:(NSString *)timerGroupID;


+ (void)createTimerGroup:(TimerGroup *) timerGroup;
+ (void)createSignal:(NSString *) timerGroupID signal:(Signal *)signal;
+ (void) createSignalRing:(NSString *) timerGroupID signalID:(NSString *) signalID signalRing:(SignalRing *) signalRing;
+ (void) createSignalPhase:(NSString *)timerGroupID signalID:(NSString *)signalID signalRingID:(NSString *)signalRingID signaPhase:(SignalPhase *)signalPhase;

+(void) removeTimerGroupByID: (NSString *) timerGroupID;
+(void) removeSignalByTimerGroupIDAndSignalID:(NSString *) timerGroupID signalID:(NSString *) signalID;
+(void) removePhaseByTimerGroupIDSignalIDAndPhaseID:(NSString*) timerGroupID signalID:(NSString *)signalID ringID:(NSString *)ringID phaseID:(NSString *)phaseID;

+(void) updateSignal:(NSString *) timerGroupID signal:(Signal *)signal;

+(void) updatePhase:(NSString *)timerGroupID signalID:(NSString *)signalID signalRingID:(NSString *)signalRingID signaPhase:(SignalPhase *)signalPhase;


//Operations of agency
+ (void) createAgency: (Agency *) agency;
+ (void) removeAgency: (NSString *) agencyID;
+ (NSArray *) getAgencyList;
+ (Agency *) getAgencyByAgencyID: (NSString *) agencyID;
+ (void) updateAgency: (Agency *) agency;
+ (NSString *) createAgencyID;


//Operations of subSystem
+ (void) createSubSystem:(SubSystem *)subSystem agencyID:(NSString *)agencyID;
+ (void) removeSubSystem:(NSString *)subSystemID agencyID:(NSString *)agencyID;
+ (NSArray *) getSubSystemList:(NSString *)agencyID;
+ (SubSystem *) getSubSystem:(NSString *)subSystemID agencyID:(NSString *)agencyID;
+(void) updateSubSystem: (SubSystem *) subSystem agencyID:(NSString *)agencyID;
+ (NSString *) createSubSystemID:(NSString *)agencyID;
//Operations of timingPattern
+ (void) createTimingPattern:(TimingPattern *)timingPattern agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID;
+ (void) duplicateTimingPattern:(TimingPattern *)timingPattern originalTimingPatternID:(NSString *)originalTimingPatternID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID;
+ (void) removeTimingPattern:(NSString *)timingPatternID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID;
+ (NSArray *) getTimingPatternList:(NSString *)agencyID subSystemID:(NSString *)subSystemID;
+ (TimingPattern *) getTimingPattern:(NSString *)timingPatternID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID;
+ (void) updateTimingPattern:(TimingPattern *)timingPattern agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID;
+ (NSString *) createTimingPatternID:(NSString *)agencyID subSystemID:(NSString *)subSystemID;

//Operations of signals
+ (void)createSignal:(Signal *) signal agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID;
+ (void) removeSignal:(NSString *) signalID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID;
+ (NSArray *) getSignalList:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID;
+ (Signal *) getSignal:(NSString *) signalID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID;
+ (void) updateSignal:(Signal *) signal agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID;
+ (NSString *) createSignalID:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID;

//Operations of links
+ (void)createLink:(Link *) link agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID ;
+ (void) removeLink:(NSString *) linkID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID ;
+ (NSArray *) getLinkList:(NSString *)agencyID subSystemID:(NSString *)subSystemID;
+ (NSArray *) getLinkListFromIntersection:(NSString *)agencyID subSystemID:(NSString *)subSystemID intersectionID:(NSString *) intersectionID;
+ (NSArray *) getLinkListToIntersection:(NSString *)agencyID subSystemID:(NSString *)subSystemID intersectionID:(NSString *) intersectionID;
+ (Link *) getLink:(NSString *) linkID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID;
+ (void) updateLink:(Link *) link agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID ;
+ (NSString *) createLinkID:(NSString *)agencyID subSystemID:(NSString *)subSystemID ;

//Operations of intersections
+ (void)createIntersection:(Intersection *) intersection agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID ;
+ (void) removeIntersection:(NSString *) intersectionID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID ;
+ (NSArray *) getIntersectionList:(NSString *)agencyID subSystemID:(NSString *)subSystemID;
+ (Intersection *) getIntersection:(NSString *) intersectionID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID;
+ (void) updateIntersection:(Intersection *) intersection agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID ;
+ (NSString *) createIntersectionID:(NSString *)agencyID subSystemID:(NSString *)subSystemID ;

//Operations of phases
+ (void)createPhase:(SignalPhase *) phase agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID signalID:(NSString *)signalID signalRingID:(NSString *)signalRingID;
+ (void) removePhase:(NSString *) phaseID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID signalID:(NSString *)signalID signalRingID:(NSString *)signalRingID;
//+ (NSArray *) getPhaseList:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID signalID:(NSString *)signalID;
//+ (SignalPhase *) getPhase:(NSString *) phaseID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID signalID:(NSString *)signalID;
+ (void) updatePhase:(SignalPhase *) phase agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID signalID:(NSString *)signalID signalRingID:(NSString *)signalRingID;
//+ (NSString *) createSignalID:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID;
+ (void) clearPhases:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID signalID:(NSString *)signalID signalRingID:(NSString *)signalRingID;


@end
